import axios from "axios";
import qs from "qs";

axios.defaults.baseURL = "/api";// 基础路径自动拼接
axios.defaults.withCredentials = true; //cors
// axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';


axios.interceptors.request.use(function (config) { //请求拦截
    if (config.method === 'post') {
        config.data = qs.stringify(config.data)
    }
    return config;
}, function (error) {
    return Promise.reject(error)
})





axios.interceptors.response.use(function (response) {//响应拦截
    return response.data
}, function (error) {
    return Promise.reject(error);
})
export default axios;